/*
 * Kelas dadu animator berisi animasi dadu
 * 
 */

package controller.permainan;

import java.util.logging.Level;
import java.util.logging.Logger;

public class Dadu_animator implements Runnable
{
    public Permainan2 P;
    public int dadu1;
    public int dadu2;
    public int dadu_time;

    public Dadu_animator (Permainan2 P,int dadu1, int dadu2)
    {
        this.P = P;
        this.dadu1 = dadu1;
        this.dadu2 = dadu2;
    }

    public void run()
    {
        dadu_time = (dadu1+dadu2) *500;
        try
        {
            P.SetDicesDisplayed(dadu1, dadu2);
            P.act_panel.setVisible(false);
            Thread.sleep(2000);
            P.HistoryWrite(P.G.current_plyr().getNama() + " rolled the dice. Dices :"+dadu1+" & "+dadu2);
            if(!P.G.current_plyr().masuk_penjara)
                P.G.current_plyr().moveYourPlayer(P, dadu1+dadu2);
            Thread.sleep(dadu_time);

            if(P.G.current_plyr().getHuman())
            {
                P.act_panel.setVisible(true);
            }
            else
            {
                P.act_panel.setVisible(false);
                P.DisableButtons();
            }
        }
        catch (InterruptedException ex)
        {
            Logger.getLogger(Dadu_animator.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    //==========================================================================
    //MAIN DRIVER
    public static void main (String [] args)
    {
        Thread t = new Thread (new Dadu_animator(new Permainan2(),1,2));
        t.start();
    }
}
